<script setup lang="ts">
import { useUserStore } from '../../stores/user';
import { useRouter } from 'vue-router';
import axios from 'axios';
const router = useRouter()

const user = useUserStore()
function logoutFn() {
  // 清除本地的数据
  localStorage.clear()
  // 清除全局状态中的数据
  user.changeUserState({
    loginState: false,
    userid: '',
    token: ''
  })
  // 跳转到登录页面中
  router.push('/login')
}


// --------------------------- 跨域问题 ------------------------------
axios.get('/api/RoomApi/live').then(res => {
  console.log(res);
})
// --------------------------- 跨域问题 ------------------------------
</script>
<template>
  <div class="box">
    <header class="header"> 用户 </header>
    <div>
      用户 内容
      <br>

      <van-button type="danger" @click="logoutFn">退出登录</van-button>



    </div>
  </div>
</template>
